<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/lib/layui/css/layui.css">
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>
<form class="layui-form searchForm" style="margin-top: 20px;">
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">企业名称：</label>
            <div class="layui-input-inline">
                <input type="text" name="orgName" id="orgName" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label" style="width: 100px;">统一信用代码：</label>
            <div class="layui-input-inline">
                <input type="text" name="creditCode" id="creditCode" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label" style="width: 100px;">企业状态：</label>
            <div class="layui-input-inline">
                <select lay-search  name="status" id="status" autocomplete="off" class="layui-input">
                    <option value="">请选择</option>
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <div class="layui-input-inline">
                <button class="layui-btn layui-btn-sm" lay-submit lay-filter="formDemo">搜索</button>
                <button class="layui-btn layui-btn-sm" >清空</button>
            </div>
        </div>
    </div>
</form>

<table class="layui-hide" id="dataList" lay-filter="dataList"></table>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit">查看</a>
    {{# if(d.status==0 || d.status==1){ }}
    <a class="layui-btn layui-btn-xs layui-btn-disabled">启用</a>
    {{# }else if(d.status==2){ }}
    <a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="statuBtn">禁用</a>
    {{# }else if(d.status==3){ }}
    <a class="layui-btn layui-btn-xs" lay-event="statuBtn">启用</a>
    {{# } }}
</script>

<script type="text/javascript" src="/lib/layui/layui.js"></script>
<script src="/static/js/main.js"></script>
<script>
    var ysb = {};
    layui.use(['jquery', 'configureCom', 'configure', 'sessionFun', 'table', 'matchDict','jsDictFile'], function () {
        var $ = layui.jquery;
        var configure = layui.configure;
        var table = layui.table;
        var sessionFun = layui.sessionFun;
        var matchDict = layui.matchDict;
        configureCom = layui.configureCom;
        var cols = [[
            {type: 'checkbox', fixed: 'left'}
            , {field: 'orgName', title: '企业名称'}
            , {field: 'creditCode', title: '统一信用代码'}
            , {field: 'provinceName', title: '所在区域',templet:function(d){
                    var areaAll="";
                    if(d.provinceName!=null&&d.provinceName!=""&&d.provinceName!="null"){
                        areaAll+=d.provinceName+",";
                    }
                    if(d.cityName!=null&&d.cityName!=""&&d.cityName!="null"){
                        areaAll+=d.cityName+",";
                    }
                    if(d.countyName!= null && d.countyName!=""&& d.countyName!="null"){
                        areaAll+=d.countyName;
                    }
                    if(areaAll!=""&&areaAll!=null&&areaAll!="null"){
                        return areaAll;
                    }
                    return "-";
                }
            }
            , {field: 'orgType',width:120, title: '企业类型',templet:function(d){
                    return matchDict.name(d.orgType, 'MENU_ORG_TYPE');
                }}
            , {field: 'status', width:180,title: '企业状态',templet:function(d){
                    return matchDict.name(d.status, 'SH_STATUS');
                }}
            , {field: 'createTime',width:180, title: '创建时间'}
            , {fixed: 'right', title: '操作', toolbar: '#barDemo', width: 150}
        ]];


        configureCom.tableRender(configure.CONSTR_COMPANY_LIST_HTTP, {}, cols, 'dataList', 10, 'full-100', 'toolbarOrg');
        configureCom.tableSearch();
    //    configureCom.selectFun('ENT_TYPE', '', '#orgType',configure.SEARCH_DICT_HTTP);
        configureCom.selectFun('SH_STATUS', '', '#status',configure.SEARCH_DICT_HTTP,'value');



//头工具栏事件
        table.on('toolbar(dataList)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            switch (obj.event) {
                case 'getCheckData':
                    var data = checkStatus.data;
                    layer.alert(JSON.stringify(data));
                    break;
                case 'getCheckLength':
                    var data = checkStatus.data;
                    layer.msg('选中了：' + data.length + ' 个');
                    break;
                case 'isAll':
                    layer.msg(checkStatus.isAll ? '全选' : '未全选');
                    break;
            }
        });

        //监听行工具事件
        table.on('tool(dataList)', function (obj) {
            var data = obj.data;
            sessionFun.set(configure.SESSION_LIST_DATA, data);
            if (obj.event === 'statuBtn') {
                layer.confirm('您确定此操作吗？', function (index) {
                    layer.close(index);
                    configureCom.postDataAjax(configure.COMPANY_STATUS_HTTP, {
                        orgId: data.orgNo
                    }).then(function (res) {
                        if (res.code == 0) {
                            configureCom.tableReload(true);
                        } else {
                            top.layer.alert('设置失败！')
                        }
                    });
                });
            } else if (obj.event === 'edit') {
                editItem('查看信息', configure.ORG_UPDATE_HTTP)
            }
        });


        //新增或修改字典详情
        function editItem(title, url) {
            top.layer.open({
                type: 2,
                title: title,
                area: configureCom.Psize1,
                content: configureCom.nocache(configure.ORG_DETAIL_HTML),
                btn: ['关闭'],
                btnAlign: 'c',
                /*yes: function (index, layero) {
                    var iframeWin = top.window.frames['layui-layer-iframe' + index]; //得到iframe页的窗口对
                    var data = iframeWin.getData();
                    console.log(data);
                    configureCom.postDataAjax(url, data).then(function (res) {
                        if (res.code == 0) {
                            top.layer.close(index);
                            top.layer.msg('保存成功！');
                            configureCom.tableReload(true);
                        } else {
                            top.layer.alert('保存失败！');
                        }
                    });
                }*/
            });
        }
    });


</script>
</body>
</html>